package com.guet.niit.Login.controller.user;

import com.guet.niit.util.UserBacktrack;
import com.sun.javafx.stage.StageHelper;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.text.Text;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

public class SelectChargingStationsFxController implements Initializable {

    public static SelectChargingStationsFxController selectChargingStationsFxController;

    @FXML
    private ImageView backtrack;

    @FXML
    private ImageView stationPhoto0;

    @FXML
    private Text stationName0;

    @FXML
    private Text address0;

    @FXML
    private Text type0;

    @FXML
    private Text expense0;

    @FXML
    private ImageView stationPhoto01;

    @FXML
    private Text stationName01;

    @FXML
    private Text address01;

    @FXML
    private Text type01;

    @FXML
    private Text expense01;

    @FXML
    private ImageView stationPhoto011;

    @FXML
    private Text stationName011;

    @FXML
    private Text address011;

    @FXML
    private Text type011;

    @FXML
    private Text expense011;

    @FXML
    private ImageView stationPhoto012;

    @FXML
    private Text stationName012;

    @FXML
    private Text address012;

    @FXML
    private Text type012;

    @FXML
    private Text expense012;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        selectChargingStationsFxController = this;
    }

    /**
     * 返回用户菜单
     * @param mouseEvent
     */
    public void backtrack(MouseEvent mouseEvent) {
        UserBacktrack.backtrack(SelectChargingStationsFxController.class);
    }

    /**
     * 查看充电站详情
     * @param mouseEvent
     */
    public void selectStationInfo(MouseEvent mouseEvent) {
        //引用fxml样式
        Parent load = null;
        try {
            load = FXMLLoader.load(getClass().getResource("/fxml/user/stationInfo.fxml"));

        } catch (IOException e) {
            e.printStackTrace();
        }
        //获取当前窗口，并将Scene更换为用户菜单的Scene
        ObservableList<Stage> stageList = StageHelper.getStages();
        stageList.get(0).setScene(new Scene(load));
    }

    /**
     * 读取个人信息
     */
//    public void readUserInfo(User user){
//        String newUsername = user.getUsername();
//        //读取用户名
//        username.setText(newUsername);
//    }
}
